<template>
  <div class="login-wrap" @keydown.enter="submit">
    <div class="ms-login">
      <div class="ms-title">欢迎登录</div>
      <el-form :model="form" :rules="rules" ref="login" label-width="0px" class="ms-content">
        <el-form-item prop="username">
          <el-input v-model.trim="form.username" placeholder="请输入用户名">
            <i slot="prepend" class="el-icon-user"></i>
          </el-input>
        </el-form-item>

        <el-form-item prop="password">
          <el-input type="password" v-model="form.password" placeholder="请输入密码" @keyup.enter.native="submit">
            <i slot="prepend" class="el-icon-lock"></i>
          </el-input>
        </el-form-item>

        <div @click="submit" class="login-btn">登录</div>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data() {
    return {
      form: {
        username: 'admin',
        password: '123456'
      },
      rules: {
        username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
        password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
      }
    }
  },
  methods: {
    submit() {
      this.$refs.login.validate((valid) => {
        if (valid) {
          if (this.form.username == 'admin' && this.form.password == '123456') {
            sessionStorage.setItem('login', 'ok')
            this.$router.push('/')
            this.$message.success('登录成功')
          }else{
            this.$message.error('账号或密码错误')
          }
        } else {
          this.$message.error('请输入账号和密码')
        }
      })
    }
  }
}
</script>

<style lang='less' scoped>
.login-wrap {
  position: relative;
  width: 100%;
  height: 100vh;
  background: url(~_img/login-bg.jpg);
  background-size: 100% 100%;
  /* background: #324157; */
  .logo {
    width: 350px;
    position: absolute;
    left: 50%;
    top: 24%;
    transform: translate(-50%, -50%);
  }
  /deep/.el-input-group__prepend {
    background: #253a52;
    text-align: center;
    width: 50px;
    height: 50px;
    padding: 0;
    border: none;
  }
  i {
    width: 50px;
    height: 50px;
    line-height: 50px;
    background: rgba(24, 45, 65, 0);
    box-shadow: 0px 2px 6px 0px rgba(139, 255, 218, 0.25);
    border-radius: 8px 0px 0px 8px;
    padding: 0;
    font-size: 24px;
  }
  .el-input {
    margin: 10px 0 10px;
    /deep/input {
      border: none;
      color: #f4df71;
      font-size: 16px;
      height: 50px;
      background: rgba(78, 96, 118, 0.8);
      box-shadow: 0px 2px 8px 0px #182d41, 0px -2px 6px 0px rgba(139, 251, 255, 0.4);
    }
  }
}

.ms-title {
  width: 100%;
  line-height: 50px;
  text-align: center;
  color: #fff;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
  font-family: JLinXin;
  color: #f4df71;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.56), 0px 0px 10px rgba(255, 142, 50, 0.76);
}

.ms-login {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 438px;
  height: 438px;
  background: rgba(96, 111, 131, 0.6);
  box-shadow: 0px 8px 18px 0px rgba(0, 0, 0, 0.84);
  border-radius: 12px;
}

.ms-content {
  padding: 30px 30px;
}

.login-btn {
  text-align: center;
  width: 320px;
  height: 50px;
  line-height: 50px;
  margin: 60px auto 0;
  background: #6baaff;
  box-shadow: 0px 3px 6px 0px #8bf8ff, 0px -4px 6px 0px rgba(22, 33, 50, 0.46);
  border-radius: 8px;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 10px;
  color: #f4df71;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.56), 0px 0px 10px rgba(255, 142, 50, 0.76);
  cursor: pointer;
}

.login-tips {
  font-size: 12px;
  line-height: 30px;
  color: #fff;
}
</style>